package com.uphone.kingmall.base;

import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.tencent.tauth.IUiListener;
import com.tencent.tauth.UiError;

import org.json.JSONObject;

/**
 * <pre>
 *     author : radish
 *     e-mail : 15703379121@163.com
 *     time   : 2019/4/1
 *     desc   :
 * </pre>
 */
public abstract class BaseUiListener0 implements IUiListener {


    @Override
    public void onComplete(Object response) {
        if (null == response) {
//            "返回为空", "登录失败"
            LogUtils.e("返回为空", "登录失败");
            return;
        }
        JSONObject jsonResponse = (JSONObject) response;
        if (null != jsonResponse && jsonResponse.length() == 0) {
//            "返回为空", "登录失败")
            LogUtils.e("返回为空", "登录失败");
            return;
        }
        LogUtils.e("登录成功");
        doComplete(jsonResponse);
    }
    /**
     * 登录成功后的操作
     *
     * @param values
     */
    protected abstract void doComplete(JSONObject values);



    @Override
    public void onError(UiError e) {
        ToastUtils.showShort("onError: " + e.errorDetail);
    }

    @Override
    public void onCancel() {
        // 取消登陆
        LogUtils.e("onCancel: ");
    }
}
